package com.fengkai.filepost.pdfoutstream.test.ODsolutions;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

/**
 * @author Fengkai
 * 给定一个非空数组（列表），其元素数据类型为整型，请按照数组元素十进制最低位从小到大进行排序，十进制最低位相同的元素，相对位置保持不变。
 * 当数组元素为负值时，十进制最低位等同于去除符号位后对应十进制值最低位。
 * @creat 2023/4/2
 */
public class SortByOne {

    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split(" ");
        int[] ints = new int[s.length];
        for (int i = 0; i < s.length; i++) {
            ints[i] = Integer.parseInt(s[i]);
        }
        System.out.println(getSortedArray(ints));

    }

    public static String getSortedArray (int[] nums) {
        StringBuilder stringBuilder = new StringBuilder();
        HashMap<Integer, List<String>> integerListHashMap = new HashMap<>();
        for (int num : nums) {
            int i = Math.abs(num) % 10;
            List<String> orDefault = integerListHashMap.getOrDefault(i, new ArrayList<String>());
            orDefault.add(num + ",");
            integerListHashMap.put(Math.abs(num) % 10, orDefault);
        }
        for (int i = 0; i < 10; i++) {
            List<String> strings = integerListHashMap.get(i);
            if (strings == null ||strings.size() ==0){
                continue;
            }else {
                strings.forEach(v -> {
                    stringBuilder.append(v);
                });
            }
        }
        return stringBuilder.substring(0, stringBuilder.length() - 1);
    }
}
